package edu.pw.treegrid.server.web.converters;


import edu.pw.treegrid.server.reportmodel.ReportColumn;
import edu.pw.treegrid.server.reportmodel.ReportSimpleColumn;
import edu.pw.treegrid.server.service.TreeGridService;
import edu.pw.treegrid.shared.ReportColumnDescription;
import xalan.smartgwt.record.BeanToRecordConverter;
import xalan.smartgwt.record.Record;

public class ReportColumnConverter implements
                BeanToRecordConverter<ReportColumn> {
		
		TreeGridService service;
        public void setService(TreeGridService service) {
			this.service = service;
		}



		@Override
        public void convert(Record record, ReportColumn column) {
                ReportSimpleColumn rsc = column.getReportSimpleColumn();
                record.addParam(ReportColumnDescription.NAME, column.getName());
                record.addParam(ReportColumnDescription.TITLE, service.getColumnTitle(rsc));
                record.addParam(ReportColumnDescription.TYPE, rsc.getType());
                record.addParam(ReportColumnDescription.IMAGE_SRC, rsc.getImageSrc());
                record.addParam(ReportColumnDescription.CATEGORY, rsc.getCategory());
                record.addParam(ReportColumnDescription.FORMAT, rsc.getFormat());
                record.addParam(ReportColumnDescription.DESCRIPTION, rsc.getDescription());
                record.addParam(ReportColumnDescription.WIDTH, rsc.getWidth());
        }

}
